home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- * APLMALLO.C - Internal service routines apl_malloc(), apl_free().
- *
- * All memory allocation done by GemFast internals goes through these
- * routines. By default, the standard runtime lib allocator is used.
- *************************************************************************/
-
- #include "gemfintl.h"
- #include <stdlib.h>
-
- #if defined(LATTICE) || defined(__GNUC__) || defined(__TURBCOC__)
- #define DefaultAllocate(size) malloc(size)
- #define DefaultRelease(block) free(block)
- #else
- #define DefaultAllocate(size) lalloc(size)
- #define DefaultRelease(size) free(size)
- #endif
-
- typedef void * (VPFUNC) __PROTO((unsigned long));
- typedef void (VFUNC) __PROTO((void *));
-
- static VPFUNC *allocator = NULL;
- static VFUNC *releaser = NULL;
-
- void *apl_malloc(size)
- unsigned long size;
- {
- if (allocator) {
- return (*allocator)(size);
- } else {
- return DefaultAllocate(size);
- }
- }
-
- void apl_free(block)
- void *block;
- {
- if (block) {
- if (releaser) {
- (*releaser)(block);
- } else {
- DefaultRelease(block);
- }
- }
- }
-
- void apl_mmvectors(newalloc, newrelease)
- void *newalloc;
- void *newrelease;
- {
- if (newalloc && newrelease) {
- allocator = (VPFUNC *)newalloc;
- releaser = (VFUNC *)newrelease;
- }
- }
-
-
-